#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100010;
int n, m, a[Maxn], f[Maxn][33];

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    f[i][0] = a[i];
  }
  for (int j = 1; j <= 20; ++j)
    for (int i = 1; i <= n + 1 - (1 << j); ++i)
      f[i][j] = min(f[i][j - 1], f[i + (1 << (j - 1))][j - 1]);
  int l = 1, r = m;
  int w = 0;
  while ((1 << w) <= m) ++w;
  --w;
  while (l <= n - m + 1 && r <= n) {
    printf("%d\n", min(f[l][w], f[r - (1 << w) + 1][w]));
    l++, r++;
  }
}
